<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<form action="http://www.test8899.com/reg.php" method="post">	
		<table border="1" cellspacing="0" cellpadding="10px" id='tableId'>
			<tr>
				<th></th>
				<th>姓名</th>
				<th>性别</th>
				<th>年龄</th>
				<th>家庭住址</th>
			</tr>
			<tr>
				<td><input type="checkbox" name="stu" id="" value="nv" /></td>
				<td>张三1</td>
				<td>女</td>
				<td>19</td>
				<td>福建省新罗区</td>
			</tr>
			<tr>
				<td><input type="checkbox" name="stu" id="" value="nan" /></td>
				<td>张三2</td>
				<td>男</td>
				<td>19</td>
				<td>福建省新罗区</td>
			</tr>
			<tr>
				<td><input type="checkbox" name="stu" id="" value="nan" /></td>
				<td>张三3</td>
				<td>男</td>
				<td>19</td>
				<td>福建省新罗区</td>
			</tr>
			<tr>
				<td><input type="checkbox" name="stu" id="" value="nv" /></td>
				<td>张三4</td>
				<td>女</td>
				<td>19</td>
				<td>福建省新罗区</td>
			</tr>
			<tr>
				<td><input type="checkbox" name="stu" id="" value="nv" /></td>
				<td>张三5</td>
				<td>女</td>
				<td>19</td>
				<td>福建省新罗区</td>
			</tr>
			<tr>
				<td><input type="checkbox" name="stu" id="" value="nan" /></td>
				<td>张三6</td>
				<td>男</td>
				<td>19</td>
				<td>福建省新罗区</td>
			</tr>
		</table>
		<td><input type="checkbox" name="" id="checkAllID" value="" onclick="checkAll();"/></td>全选
		<td><input type="checkbox" name="" id="checkAllID1" value="" onclick="checkAll1();" /></td>全选男
		<td><input type="checkbox" name="" id="checkAllID2" value="" onclick="checkAll2();" /></td>全选女
		<button type="submit">删除</button>
		
		
		</form>
	</body>
	<script type="text/javascript">
			var tableOjb = document.getElementById('tableId');
			var allSelInput = tableOjb.getElementsByTagName('input');
			var checkAllIDValue = document.getElementById('checkAllID');
			var man = document.getElementById('checkAllID1')
			var woman = document.getElementById('checkAllID2')
			function checkAll(){
				 for (var i=0 ;i<allSelInput.length;i++){
					 allSelInput[i].checked = checkAllIDValue.checked;
				 }
			}
			function checkAll1(){
				for (var i = 0; i < allSelInput.length; i++) {
								if(allSelInput[i].value == 'nan'){
									allSelInput[i].checked = man.checked
								}
								}
			}
			function checkAll2(){
				for(var i=0;i<allSelInput.length;i++){
					if(allSelInput[i].value=='nv'){
						allSelInput[i].checked=woman.checked;
					}
				}
			}
	</script>
</html>
